﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EC_Agent.Models;
using EC_Agent.AgentClass;
using System.Web.Security;
using System.Data;
using System.Data.SqlClient;

namespace EC_Agent
{
    public partial class HistoryOfTransaction : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["IsLogin"] != null && (bool)Session["IsLogin"])
            {
                LabWelcome.Visible = true;
                LabUser.Text = Session["Username"].ToString();
                LabUser.Visible = true;
                DangNhap.Attributes.Add("style", "display:none");
                DangKy.Attributes.Add("style", "display:none");
                HoaDonGiaoDichModels HoaDon = new HoaDonGiaoDichModels();
                DataSet travel = HoaDon.GetHoaDonGD_Travel(Session["Username"].ToString());
                DataSet hotel = HoaDon.GetHoaDonGD_Hotel(Session["Username"].ToString());
                DataSet transport = HoaDon.GetHoaDonGD_Transport(Session["Username"].ToString());
                DataSet airplane = HoaDon.GetHoaDonGD_Airplane(Session["Username"].ToString());

                if (travel.Tables[0].Rows.Count == 0)
                {
                    Travel.Attributes.Add("style", "display:none");
                }

                if (hotel.Tables[0].Rows.Count == 0)
                {
                    Hotel.Attributes.Add("style", "display:none");
                }

                if (transport.Tables[0].Rows.Count == 0)
                {
                    Transport.Attributes.Add("style", "display:none");
                }

                if (airplane.Tables[0].Rows.Count == 0)
                {
                    Airplane.Attributes.Add("style", "display:none");
                }

                gvTravel.DataSource = travel;
                gvTravel.DataBind();

                gvHotel.DataSource = hotel;
                gvHotel.DataBind();

                gvTransport.DataSource = transport;
                gvTransport.DataBind();

                gvAirplane.DataSource = airplane;
                gvAirplane.DataBind();

            }
            else
            {
                UpdateInfo.Attributes.Add("style", "display:none");
                LichSuGD.Attributes.Add("style", "display:none");
                Logout.Attributes.Add("style", "display:none");

                Travel.Attributes.Add("style", "display:none");
                Hotel.Attributes.Add("style", "display:none");
                Transport.Attributes.Add("style", "display:none");
                Airplane.Attributes.Add("style", "display:none");
            }
        }
    }
}